<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--图标库-->
<link rel="stylesheet" href="<!--{BASE_URL}-->/static/css/login_regist/all.min.css">

<!--响应式框架-->
<link rel="stylesheet" href="<!--{BASE_URL}-->/static/css/login_regist/bootstrap.min.css">

<!--主要样式-->
<link rel="stylesheet" href="<!--{BASE_URL}-->/static/css/login_regist/style.css">

<script type="text/javascript" src="<!--{BASE_URL}-->/static/js/jquery.min.js"></script>
<script type="text/javascript" src="<!--{BASE_URL}-->/static/lib/layui/layui.all.js"></script>
<link rel="stylesheet" href="<!--{BASE_URL}-->/static/lib/layui/css/layui.css">
</head>
<body>

<div class="container" style="margin-top: -100px;">

	<div class="card-wrap">

		<div class="card border-0 shadow card--welcome is-show" id="welcome">
			<div class="card-body">
				<h2 class="card-title">欢迎光临</h2>
				<p>欢迎进入登录页面</p>
				<div class="btn-wrap">
					<a class="btn btn-lg btn-login js-btn" data-target="login" style="margin-top: 10px">登录</a>
					<a class="btn btn-lg btn-register js-btn" data-target="register">注册</a>
				</div>
			</div>
		</div>

		<div class="card border-0 shadow card--register" id="register">
			<div class="card-body">
				<h2 class="card-title">会员注册</h2>
				<form>
					<div class="form-group">
						<input class="form-control" name="account" type="text" placeholder="账号">
					</div>
					<div class="form-group">
						<input class="form-control" name="password" type="password" placeholder="密码">
					</div>
					<div class="form-group">
						<input class="form-control" name="confirm_password" type="password" placeholder="确认密码">
					</div>
					<span class="btn btn-lg do-register">注册</span>
				</form>
			</div>
			<button class="btn btn-back js-btn" data-target="welcome"><i class="fas fa-angle-left"></i></button>
		</div>

		<div class="card border-0 shadow card--login" id="login">
			<div class="card-body">
				<h2 class="card-title">欢迎登录！</h2>
				<form action="#" method="post">
					<div class="form-group">
						<input class="form-control" name="account" type="text" placeholder="账号">
					</div>
					<div class="form-group">
						<input class="form-control" name="password" type="password" placeholder="密码">
					</div>
					<span class="btn btn-lg do-login">登录</span>
				</form>
			</div>
			<button class="btn btn-back js-btn" data-target="welcome"><i class="fas fa-angle-left"></i></button>
		</div>
	</div>
</div>

<script src="<!--{BASE_URL}-->/static/js/login_regist/index.js"></script>

<script type="text/javascript">
	$(".do-register").click(function() {
		var params = {
			'account': $('#register input[name="account"]').val(),
			'password': $('#register input[name="password"]').val(),
			'confirm_password': $('#register input[name="confirm_password"]').val(),
		}
		if (params.account == ''){
			layer.msg('账号不能为空', {icon: 2,shade:0.2,time:1200});
			return;
		}
		if (params.password == ''){
			layer.msg('密码不能为空', {icon: 2,shade:0.2,time:1200});
			return;
		}
		if (params.confirm_password == ''){
			layer.msg('确认密码不能为空', {icon: 2,shade:0.2,time:1200});
			return;
		}
		if (params.confirm_password != params.password){
			layer.msg('两次密码不相等', {icon: 2,shade:0.2,time:1200});
			return;
		}
		var url = "<!--{:Router::buildUrl('User_Register')}-->";
		$.post(url, params, function(r) {
			if(r.status) {
				layer.msg('注册成功', {icon: 1,shade:'#fff',time:2000},function(){
					location.href = r.data.baseUrl;
				});
			} else {
				layer.msg(r.msg, {icon: 2,shade:0.2,time:1200});
			}
		}, "json");
	});
	$(".do-login").click(function() {
		var params = {
			'account': $('#login input[name="account"]').val(),
			'password': $('#login input[name="password"]').val(),
		}
		if (params.account == ''){
			layer.msg('账号不能为空', {icon: 2,shade:0.2,time:1200});
			return;
		}
		if (params.password == ''){
			layer.msg('密码不能为空', {icon: 2,shade:0.2,time:1200});
			return;
		}
		var url = "<!--{:Router::buildUrl('User_Login')}-->";
		$.post(url, params, function(r) {
			if(r.status) {
				layer.msg('登陆成功', {icon: 1,shade:'#fff',time:2000},function(){
					location.href = r.data.baseUrl;
				});
			} else {
				layer.msg(r.msg, {icon: 2,shade:0.2,time:1200});
			}
		}, "json");
	});
</script>
</body></html>
